BITS 32
extern tsss
extern obtener_sig_gdt_libre
extern gdt
global inicializarti
inicializarti:
	enter 0,0
	push esi
	push edi
	push ebx

	mov edi,tsss
	add edi,104*0
	mov eax,cr3
	mov [edi+28],eax
	mov dword [edi+32],0x0001200
	mov dword [edi+36],0x00000002
	mov dword [edi+56],esp
	mov dword [edi+60],ebp
	mov word [edi+72],es
	mov word [edi+76],cs
	mov word [edi+80],ss
	mov word [edi+84],ds
	mov word [edi+88],fs
	mov word [edi+92],gs
	mov word [edi+102],0xFFFF

	call obtener_sig_gdt_libre	
	
	
	mov esi, gdt
	add esi, eax
	mov word [esi], 0x67
	mov word [esi+2], di
	mov edx, edi
	shr edx, 16
	mov byte [esi+4], dl
	mov byte [esi+5], 10001001b
	mov byte [esi+6], 00010000b
	mov byte [esi+7], dh
	
	mov ax,0x28
	ltr ax
	
fin:		
	pop ebx
	pop edi
	pop esi
	leave
	ret
